<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <table border="1">
        <caption>个人信息</caption>
        <tr>
            <td>照片:</td>
            <!--加:代表属性添加的是变量,不加就写死了-->
            <td><img :src="person.imgUrl" width="50px" alt=""></td>
        </tr>
        <tr>
            <td>名字:</td>
            <td>{{person.name}}</td>
        </tr>
        <tr>
            <td>年龄:</td>
            <td>{{person.age}}</td>
        </tr>
        <tr>
            <td>好友:</td>
            <td>
                <ul>
                    <li v-for="name in person.friend">{{name}}</li>
                </ul>
            </td>
        </tr>
    </table>
    <input type="button" value="请求数据" @click="f()">
</div>
<!--script: 脚本（程序）（计算机的一系列指令）-->
<script src="../js/vue.js"></script>
<script>
    let v = new Vue({
        /*大括号里面的键值对都是:*/
        /*其他大部分是=*/
        el: "div",
        data: {
            person: {
                name: "xxx", age: "xxx",
                imgUrl: "../day05/head.jpg", friend: ["xxx", "xxx"]
            }
        },
        methods: {
            f() {
                //模拟从服务器获取的数据
                let person = {
                    name: "苍老师", age: 50, imgUrl: "../day05/a.jpg",
                    friend: ["克晶", "传奇", "成恒"]
                };
                v.person = person;
            }
        }
    })
</script>
</body>
</html>